import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
# 让浏览器不显示自动化测试

# 进入之马工场登录

driver.get("https://u.zhimawork.com/web/register.php")
driver.maximize_window()

content = {
    "name": "aa",  # 姓名
    "gender": "2",  # 1 男 2女
    "phone": "15398081985",  # 联系方式
    "email": "792595663@qq.com"  # 邮箱号
}

# 姓名输入
driver.find_element(By.ID,'user_name').send_keys(content["name"])
# 性别选择
time.sleep(2)
if content["gender"] == "1":
    gender = driver.find_element(By.XPATH,'//*[@id="useredit_form"]/div/p[2]/input[1]')
else:
    gender = driver.find_element(By.XPATH,'//*[@id="useredit_form"]/div/p[2]/input[2]')

gender.click()

# 手机号输入
driver.find_element(By.ID,'user_cellphone').send_keys(content["phone"])
# 邮箱
driver.find_element(By.ID,'user_mail').send_keys(content["email"])

# 所在地选择
area_select = driver.find_element(By.ID,'current_province').click()
time.sleep(2)
driver.find_element('xpath', '//option[text()="北京市"]').click()
# sel = Select(area_select)
# time.sleep(2)
# sel.select_by_visible_text('北京市')# 默认选择北京
# time.sleep(5)
# 申请角色
job_select = driver.find_element(By.ID,'job').click()
time.sleep(2)
# 测试归属于产品工程师
driver.find_element('xpath', '//option[text()="产品工程师"]').click()
# driver.find_element('xpath', '//option[text()="设计师"]').click()
# driver.find_element('xpath', '//option[text()="PHP开发工程师"]').click()
# driver.find_element('xpath', '//option[text()="前端工程师"]').click()

# sel = Select(job_select)
# sel.select_by_index(-1) # 默认 其他

# 从何得知平台
from_select = driver.find_element(By.ID,'where')
driver.find_element('xpath', '//option[text()="朋友推荐"]').click()

# sel = Select(from_select)
# sel.select_by_index(-1)  # 默认 其他
time.sleep(2)
recomend = driver.find_element(By.ID,'whereremark')
recomend.send_keys("心猿码")
# 申请理由
res = driver.find_element(By.XPATH,'//*[@id="useredit_form"]/div/p[9]/input[2]')
time.sleep(1)
res.click()

# 提交
# driver.find_element(By.ID,'btn_submit').click()
# 关闭浏览器
# driver.quit()

